//
//  LYYNavigationController.m

//  Copyright (c) 2015年 李岩岩. All rights reserved.
//

#import "LYYNavigationController.h"

@interface LYYNavigationController ()

@end

@implementation LYYNavigationController

/**
 *第一次使用这个类的时候会调用（1个类只会调用1次）
 */
+ (void)initialize{

    //1.设置导航栏主题
    [self setupNavBarTheme];
    //2.设置导航栏按钮主题
    [self setupBarButtonItemTheme];
    
}

/*
 设置导航栏按钮主题
 */

+ (void)setupBarButtonItemTheme{
    
    UIBarButtonItem *item = [UIBarButtonItem appearance];
    
    
    
    //返回按钮的文字颜色和大小
    NSMutableDictionary *textAttrs = [NSMutableDictionary dictionary];
    textAttrs[NSForegroundColorAttributeName] = [UIColor whiteColor];
    textAttrs[NSFontAttributeName] = [UIFont boldSystemFontOfSize:15];
    
    
    //设置文字属性
    [item setTitleTextAttributes:textAttrs forState:UIControlStateNormal];
    [item setTitleTextAttributes:textAttrs forState:UIControlStateHighlighted];
 
    //左侧返回键属性
    [item setTintColor:[UIColor whiteColor]];
    
    
    
    
}

/**
 * 1.设置导航栏主题
 */
+ (void)setupNavBarTheme{
    
    //取出appearance对象
    UINavigationBar *navBar = [UINavigationBar appearance];
    
    navBar.barTintColor = HGNavBarColor; //[UIColor colorWithRed:81/255.0 green:176/255.0 blue:251/255.0 alpha:1];

    
    
    
    //设置navBar的背景图片
    
//    [navBar setBackgroundImage:[UIImage imageNamed:@"nav"] forBarMetrics:UIBarMetricsDefault];

    //设置字体颜色
    NSMutableDictionary *textAttrs = [NSMutableDictionary dictionary];
    textAttrs[NSForegroundColorAttributeName] = HGNavBarTitleColor; //LYYTabBarButtonTitleSelectedColor;
    textAttrs[NSFontAttributeName] = [UIFont boldSystemFontOfSize:HGNavBarTitleFont];

    [navBar setTitleTextAttributes:textAttrs];
}

- (void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated
{
    if (self.viewControllers.count > 0) {
        viewController.hidesBottomBarWhenPushed = YES;
    }
    
    [super pushViewController:viewController animated:YES];
}

@end
